﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Wizard.Data
{
    /// <summary>
    /// This is a type safe WeakReference to avoid unnescessary casts.
    /// </summary>
    /// <typeparam name="K"></typeparam>
    internal class WeakRef<K>
    {
        private WeakReference mWeakReference;

        public WeakRef(K target)
        {
            mWeakReference=new WeakReference(target,false);
        }

        public virtual K Target {
            get {
                return (K)mWeakReference.Target;
            }
            set
            {
                mWeakReference.Target = value;
            }
        }

    }
}
